<template>
  <div class="avue-sidebar">
    <logo></logo>
    <el-scrollbar style="height:100%">
      <div
        v-if="validatenull(menu)"
        class="avue-sidebar--tip"
      >没有发现菜单
      </div>
      <el-menu
        unique-opened
        :default-active="nowTagValue"
        mode="vertical"
        :show-timeout="200"
        background-color="#20222a"
        text-color="#fff"
        active-text-color="#ffd04b"
        :collapse="keyCollapse"
      >
        <sidebar-item
          :menu="menu"
          :screen="screen"
          first
          :props="website.menu.props"
          :collapse="keyCollapse"
        ></sidebar-item>
      </el-menu>
    </el-scrollbar>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import logo from "../logo";
import sidebarItem from "./sidebarItem";

export default {
  name: "sidebar",
  components: { sidebarItem, logo },
  data () {
    return {};
  },
  created () {
    this.$store.dispatch("GetMenu", { type: true, id: 0 }).then(data => {
      var datas = [{ "id": 1000, "parentId": 0, "children": [{ "id": 1100, "parentId": 1000, "children": [], "icon": "icon-yonghuguanli", "name": "用户管理", "spread": false, "path": "/admin/user/index", "keepAlive": "0", "permission": null, "type": "0", "label": "用户管理", "sort": 1, "hasChildren": null }, { "id": 1200, "parentId": 1000, "children": [], "icon": "icon-caidanguanli", "name": "菜单管理", "spread": false, "path": "/admin/menu/index", "keepAlive": "0", "permission": null, "type": "0", "label": "菜单管理", "sort": 2, "hasChildren": null }, { "id": 1300, "parentId": 1000, "children": [], "icon": "icon-jiaoseguanli", "name": "角色管理", "spread": false, "path": "/admin/role/index", "keepAlive": "0", "permission": null, "type": "0", "label": "角色管理", "sort": 3, "hasChildren": null }, { "id": 1400, "parentId": 1000, "children": [], "icon": "icon-web-icon-", "name": "部门管理", "spread": false, "path": "/admin/dept/index", "keepAlive": "0", "permission": null, "type": "0", "label": "部门管理", "sort": 4, "hasChildren": null }], "icon": "icon-quanxianguanli", "name": "权限管理", "spread": false, "path": "/admin", "keepAlive": "0", "permission": null, "type": "0", "label": "权限管理", "sort": 0, "hasChildren": null }, { "id": 2000, "parentId": -1, "children": [{ "id": 2100, "parentId": 2000, "children": [], "icon": "icon-rizhiguanli", "name": "日志管理", "spread": false, "path": "/admin/log/index", "keepAlive": "0", "permission": null, "type": "0", "label": "日志管理", "sort": 5, "hasChildren": null }, { "id": 2200, "parentId": 2000, "children": [], "icon": "icon-navicon-zdgl", "name": "字典管理", "spread": false, "path": "/admin/dict/index", "keepAlive": "0", "permission": null, "type": "0", "label": "字典管理", "sort": 6, "hasChildren": null }, { "id": 2400, "parentId": 2000, "children": [], "icon": "icon-shouji", "name": "终端管理", "spread": false, "path": "/admin/client/index", "keepAlive": "0", "permission": "", "type": "0", "label": "终端管理", "sort": 9, "hasChildren": null }, { "id": 2500, "parentId": 2000, "children": [], "icon": "icon-server", "name": "服务监控", "spread": false, "path": "http://127.0.0.1:5001", "keepAlive": "0", "permission": null, "type": "0", "label": "服务监控", "sort": 10, "hasChildren": null }, { "id": 2300, "parentId": 2000, "children": [], "icon": "icon-denglvlingpai", "name": "令牌管理", "spread": false, "path": "/admin/token/index", "keepAlive": "0", "permission": null, "type": "0", "label": "令牌管理", "sort": 11, "hasChildren": null }, { "id": 2600, "parentId": 2000, "children": [], "icon": "icon-denglvlingpai", "name": "其他设置", "spread": false, "path": "/admin/token/index", "keepAlive": "0", "permission": null, "type": "0", "label": "其他设置", "sort": 11, "hasChildren": null }], "icon": "icon-xitongguanli", "name": "系统管理", "spread": false, "path": "/setting", "keepAlive": "0", "permission": null, "type": "0", "label": "系统管理", "sort": 1, "hasChildren": null }, { "id": 4000, "parentId": -1, "children": [{ "id": 4100, "parentId": 4000, "children": [], "icon": "icon-erji-zuhushouye", "name": "房产管理", "spread": false, "path": "/market/estate/rmproject/index", "keepAlive": "0", "permission": "", "type": "0", "label": "房产管理", "sort": 0, "hasChildren": null }, { "id": 4200, "parentId": 4000, "children": [], "icon": "icon-bangzhushouji", "name": "合同管理", "spread": false, "path": "/market/contract/person/index", "keepAlive": "0", "permission": "", "type": "0", "label": "合同管理", "sort": 1, "hasChildren": null }], "icon": "icon-zhexiantu", "name": "市场管理", "spread": false, "path": "/market", "keepAlive": "0", "permission": "", "type": "0", "label": "市场管理", "sort": 2, "hasChildren": null }, { "id": 3000, "parentId": -1, "children": [{ "id": 3100, "parentId": 3000, "children": [], "icon": "icon-mysql", "name": "数据源管理", "spread": false, "path": "/gen/datasource", "keepAlive": "1", "permission": null, "type": "0", "label": "数据源管理", "sort": 1, "hasChildren": null }, { "id": 3200, "parentId": 3000, "children": [], "icon": "icon-weibiaoti46", "name": "代码生成", "spread": false, "path": "/gen/index", "keepAlive": "0", "permission": null, "type": "0", "label": "代码生成", "sort": 2, "hasChildren": null }, { "id": 3300, "parentId": 3000, "children": [], "icon": "icon-record", "name": "表单管理", "spread": false, "path": "/gen/form", "keepAlive": "1", "permission": null, "type": "0", "label": "表单管理", "sort": 3, "hasChildren": null }, { "id": 3400, "parentId": 3000, "children": [], "icon": "icon-biaodanbiaoqian", "name": "表单设计", "spread": false, "path": "/gen/design", "keepAlive": "1", "permission": null, "type": "0", "label": "表单设计", "sort": 4, "hasChildren": null }], "icon": "icon-shejiyukaifa-", "name": "开发平台", "spread": false, "path": "/gen", "keepAlive": "1", "permission": null, "type": "0", "label": "开发平台", "sort": 3, "hasChildren": null }, { "id": 9999, "parentId": -1, "children": [], "icon": "icon-guanwangfangwen", "name": "系统官网", "spread": false, "path": "https://pig4cloud.com/#/", "keepAlive": "0", "permission": null, "type": "0", "label": "系统官网", "sort": 9, "hasChildren": null }]
      if (data.length === 0) return;
      //this.$router.$avueRouter.formatRoutes(datas, true);
      this.$router.$avueRouter.formatRoutes(data, true);
    });
  },
  computed: {
    ...mapGetters(["website", "menu", "tag", "keyCollapse", "screen"]),
    nowTagValue: function () {
      return this.$router.$avueRouter.getValue(this.$route);
    }
  },
  mounted () {
  },
  methods: {}
};
</script>
<style lang="scss" scoped>
</style>

